Hive列转行
1 | create database if not exists company; |
1 | load data local inpath '/home/hadoop/data/hive/rowtocol.txt' into table company; |
列转行表数据
1 | company.name company.deptno company.grade |
列转行SQL语句
1 | select t.dept_grade,concat_ws("|",collect_set(t.name)) |
1 | t.dept_grade _c1 |
Hive行转列
数据文件
1 | 1,tom,HuaXue:Physical:Math:Chinese |
创建表
1 | create table score( |
1 | load data local inpath '/home/hadoop/data/hive/coltorow.txt' into table score; |
1 | score.id score.name score.subject |
SQL语句
1 | select id,name,sub from |
1 | hive (company)> select id,name,sub from |
Hive的WordCount
创建表
1 | create table wc( |
加载数据
1 | load data local inpath '/home/hadoop/data/hive/wc.txt' into table wc; |
1 | select split(word,',') from wc; |
1 | word coun |
查看Hive的元数据信息
1 | mysql> select * from dbs \G; |
1 | *************************** 1. row *************************** |
Hive的Metatool
1 | [hadoop@bigdata01 hive]$ bin/metatool --help |
1 | [hadoop@bigdata01 hive]$ metatool -listFSRoot |
1 | Hive中多文件夹递归共计wordcount,文件存储在Hadoop HDFS上面 |
Hive配置多目录输入
wordcount程序,输入为多目录时候的设置
hadoop 自带的wordcount程序
1 | hadoop jar /home/hadoop/app/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.16.2.jar wordcount /hive/mutli_dir /hive/out1 |
修改mapred-site.xml 配置信息
1 | <property> |